package com.yc.sole.framework.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @Classname CheckUtil
 * @Description 基础参数校验规则
 * @Date 2021/3/24 14:30
 * @Created yxk
 **/
public class CheckUtil {
    private static CheckUtil checkUtil;

    public static CheckUtil getInstance() {
        if (null == checkUtil) {
            checkUtil = new CheckUtil();
        }
        return checkUtil;
    }

    public Boolean checkPhone(String phone) {
        //校验手机号规格
        final String REGEX_MOBILE = "^((13[0-9])|(14[5|7])|(15([0-3]|[5-9]))|(16([0-9]))|(17[013678])|(18[0-9])|(19[0-9]))\\d{8}$";
        if (phone.length() != 11) {
            return false;
        } else {
            Pattern p = Pattern.compile(REGEX_MOBILE);
            Matcher m = p.matcher(phone);
            boolean isMatch = m.matches();
            return isMatch;
        }
    }
}
